using System;
using System.Collections.Generic;
using System.Text;
using System.Web.SessionState;
using System.Web;

namespace BLF.WWW_WWW.Wiki
{
    public class SessionFacade
    {
        /// <summary>
        /// Gets the current Session object.
        /// </summary>
        private static HttpSessionState Session
        {
            get { return HttpContext.Current.Session; }
        }

        /// <summary>
        /// Gets or sets the Login Key.
        /// </summary>
        public static string LoginKey
        {
            get
            {
                if (HttpContext.Current.User.Identity.Name == "") return null;
                return HttpContext.Current.User.Identity.Name;
            }
            set
            {
            }
        }

        /// <summary>
        /// Gets or sets the Username.
        /// </summary>
        public static string Username
        {
            get
            {
                //return (string)Session["Username"]; 
                return HttpContext.Current.User.Identity.Name;
            }
            set
            {
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the User is an Administrator.
        /// </summary>
        public static bool Admin
        {
            get
            {
                if (HttpContext.Current.User.Identity.Name == "") return false;
                bool flag = false;
                if (Session["Admin"] == null)
                {
                    flag = (new BLL.WWW_WWW.Wiki.WikiSystem()).IsAdmin(HttpContext.Current.User.Identity.Name);
                    Session["Admin"] = flag;
                }
                else
                {
                    flag = (bool)Session["Admin"];
                }
                return flag;
            }
            set
            {
                Session["Admin"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the Admin View.
        /// </summary>
        public static int AdminView
        {
            get
            {
                if (Session["AdminView"] != null)
                    return (int)Session["AdminView"];
                else return -1;
            }
            set { Session["AdminView"] = value; }
        }

        /// <summary>
        /// Gets or sets the CAPTCHA string.
        /// </summary>
        public static string CaptchaString
        {
            get { return (string)Session["CaptchaString"]; }
            set { Session["CaptchaString"] = value; }
        }

        /// <summary>
        /// Gets or sets the Breadcrumbs Manager.
        /// </summary>
        public static BreadcrumbsManager Breadcrumbs
        {
            get { return (BreadcrumbsManager)Session["Breadcrumbs"]; }
            set { Session["Breadcrumbs"] = value; }
        }
    }
}
